package org.come.control;

import com.tool.tab.TabJFrame;
import com.tool.tcpimg.UIUtils;
import org.come.login.LoginBtn;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;


public class ExitDialogLogin extends JDialog implements ActionListener {
    private ImageIcon iconBack;
    // resource/NewUi/到主画面按钮
    // resource/NewUi/继续游戏按钮
    // resource/NewUi/退出游戏按钮
    private LoginBtn jixuBtn, tuichuBtn, zhuhuamianBtn;

    public ExitDialogLogin(TabJFrame tj) {
        // 退出游戏
        tuichuBtn = new LoginBtn("inkImg/newbutton/tcyx.png", false);
        tuichuBtn.setBounds(20, 176, 136, 29);
        tuichuBtn.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                // TODO Auto-generated method stub
                setVisible(false);
                System.exit(0);
            }
        });


        // 到主画面
        zhuhuamianBtn = new LoginBtn("inkImg/newbutton/dzhm.png", false);
//        zhuhuamianBtn.setBounds(190, 176, 136, 29);
        zhuhuamianBtn.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                // TODO Auto-generated method stub
                setVisible(false);
                //loginJpanel.framechange(0, null);
            }
        });

        // 继续游戏
        jixuBtn = new LoginBtn("inkImg/newbutton/jxyx.png", false);
        jixuBtn.setBounds(360, 176, 136, 29);
        jixuBtn.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                // TODO Auto-generated method stub
                setVisible(false);
                dispose();
            }
        });


        // 给按钮添加响应事件

        // 向对话框中加入各组件
        this.add(tuichuBtn);
        this.add(zhuhuamianBtn);
        this.add(jixuBtn);
        // 对话框流式布局
        setLayout(null);
        // 设置标题不可见
        setUndecorated(true);
        // 设置为模态窗口,此时不能操作父窗口
        setModal(true);
        setBackground(UIUtils.Color_BACK);
        // 设置对话框大小
        setSize(520, 220);
        // 对话框局域屏幕中央
        setLocationRelativeTo(com.tool.tab.Main.tabJFrame);
        // 对话框不可缩放
        setResizable(false);
        // 点击对话框关闭按钮时,销毁对话框
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }


    public void paint(Graphics g) {
        // TODO Auto-generated method stub

        super.paint(g);
        this.add(tuichuBtn);
        this.add(zhuhuamianBtn);
        this.add(jixuBtn);

        if (iconBack == null) {
            iconBack = new ImageIcon("inkImg/newbutton/tcts.png");
        }
        g.drawImage(iconBack.getImage(), 0, 0, 520, 220, this);


    }

    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub

    }
}
